#include <iostream>
#include <string>

// 基类Person
class Person {
protected:
    std::string id_number;
    std::string name;
public:
    Person() {
        std::cout << "请输入编号: ";
        std::getline(std::cin, id_number);
        std::cout << "请输入姓名: ";
        std::getline(std::cin, name);
    }

    void display() {
        std::cout << "编号: " << id_number << std::endl;
        std::cout << "姓名: " << name << std::endl;
    }
};

// 学生类Student，继承自Person
class Student : public Person {
private:
    std::string class_name;
    double score;
public:
    Student() {
        std::cout << "请输入班级: ";
        std::getline(std::cin, class_name);
        std::cout << "请输入成绩: ";
        std::cin >> score;
        std::cin.ignore();  // 清除输入缓冲区中的换行符
    }

    void display() {
        Person::display();
        std::cout << "班级: " << class_name << std::endl;
        std::cout << "成绩: " << score << std::endl;
    }
};

// 教师类Teacher，继承自Person
class Teacher : public Person {
private:
    std::string title;
    std::string department;
public:
    Teacher() {
        std::cout << "请输入职称: ";
        std::getline(std::cin, title);
        std::cout << "请输入部门: ";
        std::getline(std::cin, department);
    }

    void display() {
        Person::display();
        std::cout << "职称: " << title << std::endl;
        std::cout << "部门: " << department << std::endl;
    }
};

int main() {
    char choice;
    std::cout << "请输入's'表示学生，'t'表示教师，'q'表示退出: ";
    std::cin >> choice;
    std::cin.ignore();  // 清除输入缓冲区中的换行符

    while (true) {
        if (choice =='s') {
            Student student;
            student.display();
        } else if (choice == 't') {
            Teacher teacher;
            teacher.display();
        } else if (choice == 'q') {
            break;
        } else {
            std::cout << "无效的选择，请重新输入。" << std::endl;
        }

        std::cout << "请输入's'表示学生，'t'表示教师，'q'表示退出: ";
        std::cin >> choice;
        std::cin.ignore();  // 清除输入缓冲区中的换行符
    }

    return 0;
}